<?php

namespace Constructor;

class BaseValueException extends Exception
{
    public function __construct( $settingName, $value, $expectedValue = NULL, $variableType = 'setting' )
    {
        $type = gettype($value);
        if( in_array($type, array('array','object','resource')) )
        {
            $value = serialize($value);
        }
        
        $message = 'The value [ '.$value.' ] that you were trying to assign to '.$variableType.' "'.$settingName.'" is invalid';
        
        if( $expectedValue )
        {
            $message .= ' Allowed values are: '.$expectedValue.'.';
        }
        
        parent::__construct($message);
    }
}
